<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@page import="org.springframework.security.core.context.SecurityContextHolder"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>Net Position</title>
	<link rel="stylesheet" type="text/css" href="css/css/easyui.css"/>
    <link rel="stylesheet" type="text/css" href="css/css/icon.css"/>
    <link rel="stylesheet" type="text/css" href="css/css/demo.css"/>
    <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
    <script type="text/javascript" src="js/jquery.easyui.min.js"></script>

<style type="text/css">
<!--
.style3 {color: #00CC66}
.style4 {color: #003333}
-->
</style>
<script type="text/javascript">
	$(document).ready(function() {
		$("#export").click(function(){
			$.ajax({ 
				type: "POST",
			url : './netPosition',
			dataType: "json",
			contentType: 'application/json',			  
			  data:JSON.stringify({"ptype":$("#product").val()}),
			success : function(jsonData) {			
				if(jsonData!=null){
					                var table1 = $("#datatable");
					               $("#datatable").find("tr").remove();
					                $.each(jsonData, function(key,value) {
					                var rowNew = $("<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>");
					                        rowNew.children().eq(0).text(value['symbol']);
					                        rowNew.children().eq(1).text('NCMEX');
					                        rowNew.children().eq(2).text(value['ptype']);
					                        rowNew.children().eq(3).text(value['lot1']);
					                        rowNew.children().eq(4).text(value['price1']);

					                        if(value['lot2']==null){
					                        	 rowNew.children().eq(5).text('0');
					                        }
					                        else{
					                        rowNew.children().eq(5).text(value['lot2']);
					                        }
					                        if(value['price2']==null){
					                        	rowNew.children().eq(6).text('0000.00');
						                        	
					                        }
					                        else{
					                        rowNew.children().eq(6).text(value['price2']);
					                        }
					                        rowNew.children().eq(7).text(value['lot1']-value['lot2']);
					                        rowNew.children().eq(8).text(value['price3']-value['price4']);
					                        rowNew.children().eq(9).text('1000');
					                        rowNew.children().eq(10).text('30000');
					                        rowNew.children().eq(11).text('50000');
					                        rowNew.children().eq(12).text('50000');
					                        rowNew.appendTo(table1);
					                });
					                
					                var row1=$("<tr bgcolor='#CC99CC'>"+
					                		"<td ><span class='style3'></span></td>"+
					                		"<td ><span class='style3'></span></td>"+
					                		" <td ><span class='style3'></span></td>"+
					                		"<td colspan='2' ><span class='style3'></span></td>"+
					                		" <td colspan='2'><span class='style3'></span></td>"+
					                		 "<td colspan='2' ><span class='style3'></span></td>"+
					              "<td ><div align='right'><span class='style4'>Total</span></div></td>"+
					                		 "<td ><span class='style3'></span></td>"+
					                		    "<td ><span class='style3'></span></td>"+
					                		    "<td ><span class='style3'></span></td><tr>");
					                row1.appendTo(table1);
					                }
}

		}); 
		});
		
	});
</script>

</head>

<body>

<div style="width:100%; margin:0px auto;">
	<div style="width:100%; float:left; text-align:center; margin-bottom:10px;">
    <label style="padding:5px;">Exchange</label><select name="Exchange" style="width:80px; margin-right:10px;">
    <option>NCMEX</option>
   
    </select>
    
    <label style="padding:5px;">Product</label><select name="Product" style="width:110px; margin-right:10px;" id="product">
    <option>Intra</option>
    <option>CarryForward</option>
    <option>BOTH</option>
    </select>
    
    <label style="padding:5px;">DAY/NET</label><select name="DAY/NET" style="width:70px;">
    <option>DAY</option>
    <option>NET</option>
    </select>
    </div>
    
    <div style="width:100%; float:left; text-align:center; margin-bottom:10px;">
    <input name="Export" type="button" value="Export" style="background:#009999; border:none; padding:5px; width:100px; 
    color:#FFFFFF" id="export" />
    </div>

<div style="width:100%; float:left;">
<table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#999999" id="">
  <thead><tr style="background-color: navy;color:white;font-weight: bold">
    <th width="11%" rowspan="2"><div align="center">Contract Description</div></th>
    <th width="11%" rowspan="2"><div align="center">Exchange</div></th>
    <th width="8%" rowspan="2"><div align="center">Product</div></th>
    <th colspan="2"><div align="center">Buy</div></th>
    <th colspan="2"><div align="center">Sell</div></th>
    <th colspan="2"><div align="center">Net</div></th>
    <th width="8%" rowspan="2"><div align="center">LTP</div></th>
    <th width="12%" rowspan="2"><div align="center">UnRealized MTM</div></th>
    <th width="11%" rowspan="2"><div align="center">Realized MTM</div></th>
    <th width="9%" rowspan="2"><div align="center">Net MTM</div></th>
  </tr>
  <tr style="background-color: navy;color:white;font-weight: bold">
    <th width="3%"><div align="center">Lot</div></th>
    <th width="7%"><div align="center">Avg Price</div></th>
    <th width="3%"><div align="center">Lot</div></th>
    <th width="7%"><div align="center">Avg Price</div></th>
    <th width="3%"><div align="center">Lot</div></th>
    <th width="7%"><div align="center">Avg Price</div></th>
  </tr>
  </thead>
  <tbody id="datatable"></tbody>
  

</table>
</div>
</div>

</body>
</html>
